package test;

public class ArithmeticOperation {
    public static double performArithmeticOperation(double num1, double num2, char operation) {
        switch (operation) {
            case '+':
                return num1 + num2;
            case '*':
                return num1 * num2;
            default:
                throw new IllegalArgumentException("无效的运算类型");
        }
    }
    public static void main(String[] args) {
        double num1 = 5;
        double num2 = 3;
        char operation = '+';
        double result = performArithmeticOperation(num1, num2, operation);
        System.out.println(num1 + " " + operation + " " + num2 + " = " + result);
    }
}